local skel = fk.CreateSkill {
  name = "efengqi__lijian",
}

Fk:loadTranslationTable{
  ["efengqi__lijian"] = "离间",
  [":efengqi__lijian"] = "出牌阶段限一次，你可以选择两名其他角色并展示一张牌，令前者视为对后者使用【决斗】，赢者获得你展示牌，你获得败者一张牌。",
  ["#efengqi__lijian"] = "离间：展示一张牌，令两名角色决斗，赢者获得展示牌",
  ["@efengqi__lijian_first"] = "使用者",
  ["@efengqi__lijian_last"] = "被决斗",

  ["$efengqi__lijian1"] = "嗯呵呵～～呵呵～～",
  ["$efengqi__lijian2"] = "夫君，你要替妾身作主啊~",
}

skel:addEffect("active", {
  anim_type = "control",
  card_num = 1,
  target_num = 2,
  prompt = "#efengqi__lijian",
  card_filter = function (self, player, to_select, selected)
    return #selected == 0
  end,
  target_tip = function (self, player, to_select, selected, selected_cards, card, selectable, extra_data)
    if #selected > 0 then
      if to_select == selected[1] then
        return "@efengqi__lijian_first"
      elseif to_select == selected[2] then
        return { {content = "@efengqi__lijian_last", type = "warning"} }
      end
    end
  end,
  target_filter = function (self, player, to, selected, cards)
    if #selected < 2 and player ~= to and #cards > 0 then
      local duel = Fk:cloneCard("duel")
      duel.skillName = skel.name
      if #selected == 0 then
        return not to:prohibitUse(duel)
      else
        return not selected[1]:isProhibited(to, duel)
      end
    end
  end,
  times = function (self, player)
    return 1 - player:usedSkillTimes(skel.name, Player.HistoryPhase)
  end,
  can_use = function(self, player)
    return player:usedSkillTimes(skel.name, Player.HistoryPhase) == 0
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local to1, to2 = effect.tos[1], effect.tos[2]
    local cards = effect.cards
    player:showCards(cards)
    local use = room:useVirtualCard("duel", nil, to1, to2, skel.name)
    if not use then return end
    local winner, loser
    if use.damageDealt then
      if use.damageDealt[to2] then
        winner, loser = to1, to2
      elseif use.damageDealt[to1] then
        winner, loser = to2, to1
      end
    end
    if winner and winner:isAlive() then
      if room:getCardOwner(cards[1]) == player or room:getCardArea(cards[1]) == Card.DiscardPile then
        room:obtainCard(winner, cards, true, fk.ReasonPrey, winner, skel.name)
      end
    end
    if loser and not loser:isNude() and not player.dead then
      local cid = room:askToChooseCard(player, { target = loser, flag = "he", skill_name = skel.name})
      room:obtainCard(player, cid, false, fk.ReasonPrey, player, skel.name)
    end
  end,
})



return skel
